<?php
defined('_JEXEC') or die('Restricted access');
define('PATH_UPLOAD', 'uploads/message');
define('PATH_DOWNLOAD', 'download2.php?folder=message&file=');

$doc = JFactory::getDocument();
// add css
$doc->addStyleSheet( 'components/com_frmessage/public/css/message.css' );
$doc->addStyleSheet( 'components/com_popup/public/css/popup.css' ); 

// add js
//$doc->addScript(''components/com_user/public/css/sample.css');

if(JRequest::getVar('view')){
    $controller = JRequest::getVar('view');
    JLoader::register($controller.'Controller', JPATH_COMPONENT.DS.'controllers'.DS.$controller.'Controller.php');
    JLoader::register($controller.'ModelFolder', JPATH_COMPONENT.DS.'models'.DS.$controller.'.php');
    
    $controller = $controller.'Controller';
}else{
    // load BGController default
    JLoader::register('bgController', JPATH_COMPONENT.DS.'controllers'.DS.'controller.php');
    JLoader::register('bgModelbg', JPATH_COMPONENT.DS.'models'.DS.'bg.php');
    $controller = 'bgController';
}

// get and set default controller, task
$task = JRequest::getWord('task', 'display');

$controller = new $controller();
$controller->execute($task);
$controller->redirect();